import java.util.Arrays;

public class Test {
    public static void main(String[] args) {//返回数组中和为目标值的两数下标
        int[] array = {2, 7, 11, 15};
        int[] tmp = func2(array, 26);
        System.out.println(Arrays.toString(tmp));
    }

    public static int[] func2 (int[] array, int target) {
        int[] tmp = new int[]{-1, -1};
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] + array[j] == target) {
                    tmp[0] = i;
                    tmp[1] = j;
                }
            }
        }
        return tmp;
    }





    public static void main1(String[] args) {//奇数位于偶数之前
        int[] array = {1, 2, 3, 4, 5, 6, 7};
        func1(array);
        System.out.println(Arrays.toString(array));
    }

    public static void func1(int[] array) {
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            while (left < right && array[left] % 2 != 0) {
                left++;
            }
            while (left < right && array[right] % 2 == 0) {
                right--;
            }
            swap(array, left, right);
        }
    }

    public static void swap(int[] array, int i, int j) {
        int tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
}
